你可以通过设置五个属性来创建一个简单的绑定标记。下面的XAML标记展示如何完成这个操作:
XAML |
拷贝代码
|
---|---|
<!-- 简单绑定标记 --> <c1:ChartPanelObject x:Name="obj" Attach="DataX" Action="MouseMove" DataPoint="-1,-1" HorizontalAlignment="Center" VerticalAlignment="Top" Width="60" Height="50"> <c1:ChartPanelObject.RenderTransform> <TranslateTransform Y="-50"/> </c1:ChartPanelObject.RenderTransform> <Grid DataContext="{Binding RelativeSource={x:Static RelativeSource.Self},Path=Parent}" Opacity="0.8"> <Path Data="M0.5,0.5 L23,0.5 23,23 11.61165,29.286408 0.5,23 z" Stretch="Fill" Fill="#FFF1F1F1" Stroke="DarkGray" StrokeThickness="1"/> <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center"> <TextBlock Text="Value" Margin="2 0"/> <TextBlock x:Name="label" Text="{Binding DataPoint.Y, StringFormat=c2}" FontWeight="Bold" Margin="2"/> </StackPanel> </Grid> </c1:ChartPanelObject> |
请注意,您设置了以下属性:
该应用程序运行起来将类似于以下图像: